﻿// Copyright (c) 2023 raoyutian Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.InteropServices;
namespace PaddleClasSharp
{
    /// <summary>
    /// Detection结果
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public class ClasResult
    {
        /// <summary>
        /// 对象列表
        /// </summary>
        public List<ObjectResult> ObjectResults { get; set; } = new List<ObjectResult>();
        /// <summary>
        /// 结果文本Json格式
        /// </summary>
        public string JsonText { get; set; }

    }
      
    /// <summary>
        /// 对象检测
        /// </summary>
     public class ObjectResult
      { 
        /// <summary>
       /// 目标矩形范围
       /// </summary>
       public List<int> rect { get; set; } = new List<int>();
        /// <summary>
        /// 对象id
        /// </summary>
        public int class_id { get; set; }
        /// <summary>
        /// 对象名称
        /// </summary>
        public string name { get; set; }
        /// <summary>
        /// 置信度
        /// </summary>
        public float confidence { get; set; }
       
        /// <summary>
        ///对象矩形范围
        /// </summary>
        public Rectangle Rectangle
        {
            get 
            {
                if (rect.Count>=4)
                {
                    return new Rectangle(rect[0], rect[1], rect[2] - rect[0], rect[3] - rect[1]);
                }
                return new Rectangle();
            }   
        }
    }

   


}
